<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix = "c"  uri = "http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css"  href="css/bootstrap.min.css"/>
	<title>凯胜项目管理系统</title>
	<style type="text/css">
		body{
			padding-top:70px;
		}
	</style>
</head>
<body class="body">
	<%@include file="same2.jsp" %>
	
	<div class="container">
		<div class="row">
				<%@include file="same.jsp" %>
			<div class="span9" >
				<div class="clear"></div>
				<form id = "formSubmit" class="form-horizontal" action ="contact.jspx?method=add" method="post">
						<fieldset>
						<legend>添加新联系人</legend>
						<c:choose>
						<c:when test="${param.code == 1006}">
							<div class = "modal hide "  id="mymodal" >
								<div class = "modal-body" style = "text-align:center;height:40px;margin-top:50px">
										<div ><img alt="" src="img/file_success.png">添加成功！ 是否继续添加？</div>		
								</div>
								<div class = "modal-footer">
									<a href="#" class = "btn btn-primary" data-dismiss = "modal"  >是</a>
									<a href="contact.jspx?"} class = "btn " >否</a>
								</div>
							</div>
						</c:when>
					</c:choose>
						<div class="control-group">
							<label class="control-label" for="input01">姓名</label>
							<div class="controls">
								<input type="text" class="span5" id="name" name = "name"> <span style = "color:red;margin-left:5px" id ="tname"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">公司</label>
							<div class="controls">
								<input type="text" class="span5" id="company1" name = "company"><span id = "tcompany"></span>
							</div>
						</div>
						<hr>
						<div class="control-group">
							<label class="control-label" for="input01">手机</label>
							<div class="controls">
								<input type="text" class="span5" id="cellphone1" name = "cellphone"><span id = "tcellphone"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">固话</label>
							<div class="controls">
								<input type="text" class="span5" id="telphone" name = "telphone"><span id = "ttelphone"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">邮箱</label>
							<div class="controls">
								<input type="text" class="span5" id="email" name = "email" id = "email"><span id = "temail"></span>
							</div>
						</div>
						<hr>
						<div class="control-group">
							<label class="control-label" for="input01">地址</label>
							<div class="controls">
								<input type="text" class="span5" id="address1" name = "address"><span id = "taddress"></span>
							</div>
						</div>
						<hr>
						<div class="control-group">
							<label class="control-label" for="input01">主页</label>
							<div class="controls">
								<input type="text" class="span5" id="input01" name  = "mainpage">
								<p class="help-block">如：http://www.xxx.com</p>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">微博</label>
							<div class="controls">
								<select name="url">
									<option>请选择微博</option>
									<option value = "https://sina.com/">新浪微博</option>
									<option value = "https://t.qq.com/">腾讯微博 </option>
									<option value = "https://twritter.com/">Twritter</option>
							  </select>
							  <div class="input-prepend">
							 <span class="add-on" >@</span><input class="span2" id="prependedInput" size="16" type="text" x-webkit-speech="undefined" name = "web">
							 </div>
						  </div>
						 </div> 
						<div class="control-group">
							<label class="control-label" for="input01">简介</label>
							<div class="controls">
								<textarea   name = "introduce" class="span5"  id="input01" rows="6"></textarea>
							</div>
						</div>
						<div class="form-actions">
							<input id = "toaddContact" type="button" class="btn btn-primary" value = "保存">
							<a class="btn" href="contact.jspx">返回</a>
					  </div>
						</fieldset>
					</form>
				
			</div>
	</div>
</div>	
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src = "js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#myid li").eq(6).addClass("active");
			$("#myid i").eq(4).addClass("  icon-white");
			$(".control-group span").css({
				"color":"red",
				"margin-left":"5px"
			
			});
			$("#mymodal").modal("show");
			$("#name").blur(function(){
				var name = $("#name").val();
				if(name.trim().length == 0){
					$("#tname").html("*不能为空");
				}
			});
			$("#company1").blur(function(){
				var name = $("#company1").val();
				if(name.trim().length == 0){
					$("#tcompany").html("*不能为空");
				}
			});
			$("#cellphone1").blur(function(){
				var name = $("#cellphone1").val();
				var reg = /^1[3|5|8|4]\d{9}$/;
				if(name.trim().length == 0){
					$("#tcellphone").html("*不能为空");
					return;
				}else{
					if(reg.test(name)){
						return true;
					}else{
						$("#tcellphone").html("格式不正确");
					}
					
				}
				
			});
			$("#cellphone1").keyup(function(){
				$("#tcellphone").html("");
			
			});
			$("#address1").blur(function(){
				var name = $("#address1").val();
				if(name.trim().length == 0){
					$("#taddress").html("*不能为空");
				}
			});
			$("#email").blur(function(){
				var value = $("#email").val();
				var str = /^\w+@\w+(\.\w+){1,2}$/;
				if(str.test(value)){
					return true;
				}else{
					$("#temail").html("格式不正确");
				}
			});
			$("#email").keyup(function(){
				$("#temail").html("");
			
			});
			
			$("#name").keyup(function(){
				$("#tname").html("");
			
			});
			$("#company1").keyup(function(){
				
				
					$("#tcompany1").html("");
				
			});
			$("#cellphone1").keyup(function(){
				
				
					$("#tcellphone1").html("");
				
			});
			$("#address1").keyup(function(){
			
				
					$("#taddress1").html("");
				
			});
			$("#toaddContact").click(function(){
				var name = $("#name").val();
				if(name.trim().length == 0){
					$("#tname").html("*不能为空");
					
					return false;
				}
				
				var name1 = $("#company1").val();
				if(name1.trim().length == 0){
					$("#tcompany1").html("*不能为空");
					return false;
				}
				var name2 = $("#cellphone1").val();
				if(name2.trim().length == 0){
					$("#tcellphone1").html("*不能为空");
					return false;
				}
				
				var name3 = $("#address1").val();
				if(name3.trim().length == 0){
					$("#taddress1").html("*不能为空");
					return false;
				}
				alert("123");
				 var name4 = $("#cellphone1").val();
				var reg = /^1[3|5|8|4]\d{9}$/;
				if(name4.trim().length == 0){
					$("#tcellphone").html("*不能为空");
					return;
				}else{
					if(!reg.test(name4)){
						$("#tcellphone").html("格式不正确");
						return;
					}
					
				}
				
				var value = $("#email").val();
				var str = /^\w+@\w+(\.\w+){1,2}$/;
				if(str.test(value)){
					
				}else{
					$("#temail").html("格式不正确");
					return true;
				}
				
				$("#formSubmit").submit();
			});
			$(".add-on").css("color","black");
			
			
			
		});
		
		
	</script>
</body>
</html>
